package com.cs.game.core.view.pane;

import com.cs.game.core.constant.Constants;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;

import java.io.File;
import java.net.URL;

public class MyStage extends World {
    MediaPlayer mediaPlayer;

    @Override
    public void act(long now) {

    }

    public MyStage() {

//		mediaPlayer.play();
//		mediaPlayer.setOnEndOfMedia(new Runnable() {
//
//			@Override
//			public void run() {
//				mediaPlayer.seek(Duration.ZERO);
//				
//			}
//			
//		});
//		mediaPlayer.play();
    }

    public void playMusic() {
        URL url = this.getClass().getClassLoader().getResource(Constants.MP3_FROGGER_SONG_PATH);
        Media sound = new Media(new File(url.getPath()).toURI().toString());
        mediaPlayer = new MediaPlayer(sound);
        mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
        mediaPlayer.play();
    }

    public void stopMusic() {
        mediaPlayer.stop();
    }

}
